﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Microhard.WeixinMP.Models;
using Microhard.Permission.Interface;
using Microhard.WeixinMP.Interfaces;
using Microsoft.Practices.Unity;
using FluentValidation.Mvc;
using Microhard.Core;
using Microhard.Permission_MembershipImpl;

namespace Microhard.FMCG.WebUI.Areas.WX.Controllers
{
    public class InfoController : MicroHardBaseController<SendToUserInfoModel>
    {

        private ISendToUserInfo _op = null;

        [Dependency]
        public ISendToUserInfo Dic
        {
            set
            {
                base._repository = value;
                this._op = value;
            }
            get
            {
                return this._op;
            }
        }

        public override ActionResult SaveUpdate([CustomizeValidator(RuleSet = "Update")]SendToUserInfoModel model, Core.DBUtility.ScopeResult scope)
        {
            if (!ModelState.IsValid)
            {
                model.Content = HttpUtility.HtmlDecode(model.Content);
                return View("Update", model);
            }
            return base.SaveUpdate(model, scope);
        }

        public ActionResult Show(Guid id)
        {
            var model = _op.GetModelByID(id);
            return View(model);
        }

    }
}
